<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file = "lianjie.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		String ID = request.getParameter("userID");
		String ISBN = request.getParameter("ISBN");
		String userID = "";
		String bookISBN = "";
		String date = "";
		String bookname = "";
		//out.print(ID+ISBN);
		String check_id = "select * from usermassage where ID = '" + ID + "' and kind = '0'";
		ResultSet rs1 = stmt.executeQuery(check_id);
		
		Statement stmt2 = conn.createStatement(); 
		String check_isbn = "select * from booksmassage where ISBN = '" + ISBN + "'";
		ResultSet rs2 = stmt2.executeQuery(check_isbn);
		
		Statement stmt3 = conn.createStatement(); 
		String select_sql = "select * from borrowinformation where userID = '" + ID + "'and bookISBN = '" + ISBN + "'";
		ResultSet rs3 = null;
		rs3 = stmt3.executeQuery(select_sql);
		
		if(!rs1.next()){
			out.println("学号输入错误，请重新输入");
			response.setHeader("Refresh", "2;URL=return_book.jsp");
		}
		else if(!rs2.next()){
			out.print("书籍ISBN输入错误，请重新输入");
			response.setHeader("Refresh", "2;URL=return_book.jsp");
		}
		else if(!rs3.next()){
			out.print("无该借阅信息");
			response.setHeader("Refresh", "3;URL=return_book.jsp");
		}else{
			
						
				userID = rs3.getString("userID");
				bookISBN = rs3.getString("bookISBN");
				date = rs3.getString("date");
				bookname = rs3.getString("bookname");
		%>
		
		
	<!-- 借阅信息表格 -->
				<form name = "fm">
				<input type="hidden" name="userID" value="<%=ID%>">
				<input type="hidden" name="ISBN" value="<%=ISBN%>">
				<table width = "70%" border = "1" cellpadding="3" cellspacing="0">
					<tr>
						<th width = "15%">userID</th>
						<th width = "15%">bookISBN</th>
						<th width = "15%">date</th>
						<th width = "15%">bookname</th>
					</tr>
					<tr>
						<td><%=userID %></td>
						<td><%=bookISBN %></td>
						<td><%=date %></td>
						<td><%=bookname %></td>
					</tr>
				</table>
				<br><br><br>
				<div align = "center">
			
					<input type = "submit" name = "return_book" value = "确认还书" onClick = "return_book1()" style = "font-size:20px;font-family:'微软雅黑'">
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type = "submit" name = "button" value = "返回" onClick = "back_back()" style = "font-size:20px;font-family:'微软雅黑'">
				</div>
			</form>
		<%				
					
		}
	
	%>
</body>
<script>
	
	function return_book1(){
		alert("是否确认还书");
		document.fm.method = "post";
		document.fm.action = "return_book_ok.jsp";
	} 
	function back_back(){
		document.fm.action = "return_book.jsp";
	}
</script>
</html>